package com.calefk.util {
	/**
	 * Clase que permite enmascarar los valores numéricos enteros a letras
	 */
	public class MaskValue {
		
		/*kseftmpdza*/
		public static function ircrip(n:Number):String {
			var number:String = Math.floor(n) + "";
			var size:int = number.length;
			
			var result:String = "";
			
			for (var k:int = 0; k < size; k++) {
				var digit:int = int(number.charAt(k));
				var mask:String = maskDigit(digit);
				result += mask;
			}
			
			return result;
		}
		
		public static function dercrip(encrypted:String):Number {
			var size:int = encrypted.length;
			
			var result:String = "";
			
			for (var k:int = 0; k < size; k++) {
				var char:String = encrypted.charAt(k);
				var mask:String = unmaskDigit(char) + "";
				result += mask;
			}
			
			return Number(result);
		}
		
		private static function maskDigit(n:int):String {
			// kseftmpdza
			var char:String = "";
			if (n == 0) {
				char = "k";
			} else if (n == 1) {
				char = "s";
			} else if (n == 2) {
				char = "e";
			} else if (n == 3) {
				char = "f";
			} else if (n == 4) {
				char = "t";
			} else if (n == 5) {
				char = "m";
			} else if (n == 6) {
				char = "p";
			} else if (n == 7) {
				char = "d";
			} else if (n == 8) {
				char = "z";
			} else if (n == 9) {
				char = "a";
			}
			return char;
		}
		
		private static function unmaskDigit(char:String):int {
			// kseftmpdza
			var n:int;
			if (char == "k") {
				n = 0;
			} else if (char =="s") {
				n = 1;
			} else if (char == "e") {
				n = 2;
			} else if (char == "f") {
				n = 3;
			} else if (char == "t") {
				n = 4;
			} else if (char == "m") {
				n = 5;
			} else if (char == "p") {
				n = 6;
			} else if (char == "d") {
				n = 7;
			} else if (char == "z") {
				n = 8;
			} else if (char == "a") {
				n = 9;
			}
			return n;
		}
		
	}

}